package org.cubikalabs.todolist.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	import mx.core.Application;
	import mx.core.FlexGlobals;
	import mx.core.UIComponent;
	import mx.rpc.IResponder;
	
	import org.cubikalabs.todolist.business.BusinessDelegate;
	import org.cubikalabs.todolist.event.SecurityEvent;
	import org.cubikalabs.todolist.event.TodoEvent;
	import org.cubikalabs.todolist.model.ModelLocator;
	
	public class LogoutCommand implements ICommand, IResponder
	{
		public function execute(event:CairngormEvent):void
		{
			new BusinessDelegate(this).logout();
		}
		
		
		public function result(data:Object):void
		{
			FlexGlobals.topLevelApplication.setCurrentState("INSECURED");
			ModelLocator.getInstance().todoList.removeAll(); 
		}
		
		public function fault(info:Object):void
		{
			Alert.show("fails logout");
		}
	}
}